﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TTQT.TTQT_Code;
using System.Web.Services;

public partial class LienHe : System.Web.UI.Page
{
    [WebMethod()]
    public static string dataSave(string name)
    {
        return name;
    }
    
    protected void Page_Load(object sender, EventArgs e)
    {

        string action = Request.QueryString["action"];
        if(action.Equals("sendContact"))
        {
            /*
            action	sendContact
            address_contact	dIA CHI
            content_contact	noI DUNG
            email_contact	kiennn@fdsa.fd
            name_contact	nGUYEN NGOC KEN
            phone_contact	142423123
            title_contact	tIEU DE
            */
            string address_contact= TTQTCommon.isNull(Request.QueryString["address_contact"],"");
            string content_contact= TTQTCommon.isNull(Request.QueryString["content_contact"],"");
            string email_contact= TTQTCommon.isNull(Request.QueryString["email_contact"],"");
            string name_contact= TTQTCommon.isNull(Request.QueryString["name_contact"],"");
            string phone_contact= TTQTCommon.isNull(Request.QueryString["phone_contact"],"");
            string title_contact = TTQTCommon.isNull(Request.QueryString["title_contact"], "");

            int kq = 0;
            SqlConnection conn = new SqlConnection(TTQTCommon.DBConnectionString);
            SqlCommand cmd = new SqlCommand("LienHe_add", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@name_contact", name_contact);
            cmd.Parameters.AddWithValue("@address_contact", address_contact);
            cmd.Parameters.AddWithValue("@phone_contact", phone_contact);
            cmd.Parameters.AddWithValue("@email_contact", email_contact);
            cmd.Parameters.AddWithValue("@title_contact", title_contact);
            cmd.Parameters.AddWithValue("@content_contact", content_contact);
            try
            {
                conn.Open();
                kq = TTQTCommon.ToInt32(cmd.ExecuteScalar(), 0);
            }
            catch (Exception exxx)
            { }
            finally
            {
                if (conn.State == ConnectionState.Open) conn.Close();
                conn.Dispose();
                cmd.Dispose();
            }
            if(kq>0)
            {
                Response.Write("1");
                return;
            }
        }
        Response.Write("2");
    }
}
